﻿using Coldairarrow.Business.Backstage.TheRules;
using Coldairarrow.Entity.Backstage.TheRules;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers.Backstage.TheRules
{
    [Route("/Backstage/TheRules/[controller]/[action]")]
    public class BS_ReflectRuleController : BaseApiController
    {
        #region DI

        public BS_ReflectRuleController(IBS_ReflectRuleBusiness bS_ReflectRuleBus)
        {
            _bS_ReflectRuleBus = bS_ReflectRuleBus;
        }

        IBS_ReflectRuleBusiness _bS_ReflectRuleBus { get; }

        #endregion

        #region 获取

        [HttpPost]
        public async Task<PageResult<BS_ReflectRule>> GetDataList(PageInput<ConditionDTO> input)
        {
            return await _bS_ReflectRuleBus.GetDataListAsync(input);
        }

        //[HttpPost]
        //public async Task<BS_ReflectRule> GetTheData(IdInputDTO input)
        //{
        //    return await _bS_ReflectRuleBus.GetTheDataAsync(input.id);
        //}

        [HttpPost]
        public async Task<BS_ReflectRule> GetTheData()
        {
            return await _bS_ReflectRuleBus.GetDataAsync();
        }

        #endregion

        #region 提交

        [HttpPost]
        public async Task SaveData(BS_ReflectRule data)
        {
            if (data.Id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _bS_ReflectRuleBus.AddDataAsync(data);
            }
            else
            {
                await _bS_ReflectRuleBus.UpdateDataAsync(data);
            }
        }

        [HttpPost]
        public async Task DeleteData(List<string> ids)
        {
            await _bS_ReflectRuleBus.DeleteDataAsync(ids);
        }

        #endregion
    }
}